
<%@page import="com.sinba.common.user.dto.RegUserBasicDTO"%>
<%@page import="com.sinba.common.user.service.IRegisterUserService"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="org.springframework.context.ApplicationContext"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ include file="../language.jsp" %>

<%
if(session.getAttribute("password2")==null){
	response.sendRedirect( "login2.jsp?pageUrl=user/changeMobile.jsp");
	return;
}

ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
IRegisterUserService registerUserService = (IRegisterUserService)ac.getBean("registerUserService");
RegUserBasicDTO rubDTO = registerUserService.findRegUserBasicInfo((String)session.getAttribute("loginName"));
request.setAttribute("rubDTO",rubDTO);

session.setAttribute("end", "修改手机号码");
session.setAttribute("middle", "个人管理");

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title><fmt:message key="i18n.userInfo"/>-<fmt:message key="i18n.title"/></title>
<link rel="shortcut icon" href="../index/favicon.png" />
<jsp:include page="common.jsp"></jsp:include>
</head>
<body>
<jsp:include page="page_head.jsp"></jsp:include>

	<div class="row">
		<div class="col-md-12">
			<div class="box border primary">
				<div class="box-title">
					<h4><i class="fa fa-bars"></i>修改手机号码</h4>
				</div>
				<div class="box-body big">
					<h3 class="form-title">修改手机号码</h3>
					<form class="form-horizontal" role="form" action="registerUser!changeMobile.action" method="post" onsubmit="return changeBasicInfo();">
						<input type="hidden" name="rubDTO.loginName" value="${rubDTO.loginName }" />
				       	<!-- <input type="hidden" id="pi_loginUser_authCodeType" name="rubDTO.authCodeType"/> -->
				       	<input type="hidden"  name="pageUrl" value="changeMobile.jsp" />
				       	
				      <div class="form-group">
						<label class="col-sm-3 control-label">登入账号：</label>
						<div class="col-sm-9">
						  <input type="text" class="form-control" readonly="readonly" value="${rubDTO.loginName }" >
						</div>
					  </div>
				       	
					  <div class="form-group">
						<label class="col-sm-3 control-label">原手机号码：</label>
						<div class="col-sm-9">
						  <input type="hidden" id="cp_loginUserMobile" name="rubDTO.mobile" value="${rubDTO.mobile}" />
						  <input type="text" class="form-control" readonly="readonly" value="${rubDTO.mobile}" />
						</div>
					  </div>
					  
					   <div class="form-group">
						<label class="col-sm-3 control-label">原手机验证码：</label>
						<div class="col-sm-6">
						 	<input class="form-control col-sm-5" id="cp_oldAuthCode" name="rubDTO.oldAuthCode" />
						</div>
						<div class="col-sm-3">
							<input type="button" class="form-control col-sm-4" id="oldAuthCode_button" 
							onclick="getVerificationCode('Mobile','ChangeMobile','#cp_loginUserMobile','#oldAuthCode_button')"
								value="<fmt:message key="i18n.getVerificationCode"/>"  /> 
						</div>
					  </div>
					  
					  <div class="form-group">
						<label class="col-sm-3 control-label">新手机号码：</label>
						<div class="col-sm-9">
						  <input type="text" class="form-control" name="rubDTO.newMobile" id="cp_loginUserMobile_new" />
						</div>
					  </div>
					  
					  <div class="form-group">
						<label class="col-sm-3 control-label">新手机验证码：</label>
						<div class="col-sm-6">
						 	<input class="form-control col-sm-5" id="cp_validCode" name="rubDTO.authCode" />
						</div>
						<div class="col-sm-3">
							<input type="button" class="form-control col-sm-4" id="authCode_button" 
							onclick="getVerificationCode('Mobile','ChangeMobile','#cp_loginUserMobile_new','#authCode_button')"
								value="<fmt:message key="i18n.getVerificationCode"/>" /> 
								<input type="hidden" value="${session.email }" id="cp_loginName"/>
						</div>
					  </div>
					  <div class="form-group">
						<label class="col-sm-3 control-label"></label>
						<div class="col-sm-9">
						  <c:if test="${not empty session.activationTime}">
						  	<button type="submit" class="btn btn-primary" style="width:15em;"><fmt:message key="i18n.update"/></button>
							</c:if>
							<c:if test="${empty session.activationTime}">
							未激活（如需激活请联系注册时填写的运营中心）
							</c:if>
						</div>
					  </div>
					 </form>
				</div>
			</div>
		</div>
	</div>

<jsp:include page="page_foot.jsp"></jsp:include>
<script src="../scripts/user/common.js"></script>
<script type="text/javascript">

function changeBasicInfo(){
	if($('#cp_oldAuthCode').val()==''){
		alert('原手机验证码不允许为空!');
		$('#cp_oldAuthCode').focus();
		return false;
	}
	
	if($('#cp_loginUserMobile_new').val()==''){
		alert('新手机号码不允许为空');
		$('#cp_loginUserMobile_new').focus();
		return false;
	}
	
	if($('#cp_validCode').val()==''){
		alert('新手机验证码不允许为空!');
		$('#cp_validCode').focus();
		return false;
	}
	
	if($('#cp_loginUserMobile').val()==$('#cp_loginUserMobile_new').val()){
		alert('新手机与原手机一样!');
		$('#cp_logincp_loginUser').focus();
		return false;
	}
	
}

$(function(){
	document.onkeydown = function(evt){
		var evt = window.event?window.event:evt;
		if(evt.keyCode==13){
			changeBasicInfo();
		}
	}
});
</script>

				
</body>
</html>